package com.sm.service.Impl;

import com.sm.dao.NoticeDao;
import com.sm.entity.Notice;
import com.sm.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {

    @Autowired
    NoticeDao noticeDao;

    public List<Notice> findAllNotice() throws Exception {
        return noticeDao.findAllNotice();
    }

    public Notice findNoticeByNid(Integer nid) throws Exception {
        return noticeDao.findNotieNid(nid);
    }

    public void addNotice(Notice notice) throws Exception {
        notice.setDate(new Date());
        noticeDao.addNotice(notice);
    }

    public void updateNotice(Notice notice) throws Exception {
        noticeDao.updateNotice(notice);
    }

    public void updateStatus(Notice notice) throws Exception {
        noticeDao.updateStatus(notice);
    }

    public void deleteNotice(Integer nid) throws Exception {
        noticeDao.deleteNotice(nid);
    }

    public void clearNotice(Integer nid) throws Exception {
        noticeDao.clearNotice(nid);
    }

    public List<Notice> findNowNotice(Integer limit) throws Exception {
        return noticeDao.findNowNotice(limit);
    }
}
